const mongoose = require('mongoose')
const Scheme = mongoose.Schema
mongoose.connect('mongodb://localhost/code_order')

const moment = require('moment')

const orderSchema = new Scheme({
  price: {  //总价格
    type: Number,
    required: true
  },
  num: {  //菜品数量
    type: Number,
    required: true
  },
  userId: {  //用户id
    type: String,
    required: true
  },
  menuItem: {  //菜品信息
    type: Array,
    required: true
  },
  remarks: {  //备注
    type: String
  },
  tableNum: {  //桌号
    type: String,
    required: true
  },
  orderId: {  //订单号
    type: Number,
    required: true
  },
  status: {  //状态 0进行中  1已完成
    type: Number,
    default: 0
  },
  pickUpNum: {  //取餐号
    type: String,
    required: true
  },
  createTime: {  //创建时间
    type: String,
    default: moment().format("YYYY-MM-DD HH:mm:ss")
  }
})

const order = mongoose.model('order', orderSchema)
module.exports = order
